﻿
Partial Class RegisterCustomer
    Inherits System.Web.UI.Page

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        txtUserName.Focus()
        'Dim iniTime As String = Now().TimeOfDay.ToString()
        'txtIniTime.Value = iniTime
        'Dim regkey As String = OneCall.Crypt.Encrypt(iniTime, "1CHCAREREGNEWCUST")
        'regkey = Left(regkey, 6)
        'capimg.ImageUrl = "capimg.ashx?str=" & regkey
    End Sub

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Dim SQLDB As New OneCall.DataModel.OneCDataEntities

        Dim execCust As List(Of OneCall.DataModel.Customer) = (From p In SQLDB.Customers Where p.Customer_UserName = txtUserName.Text).ToList()

        If execCust.Count >= 1 Then
            panelExist.Visible = True
            panelForm.Visible = False
            SQLDB.Dispose()
            Exit Sub
        End If

        Dim NewUser As New OneCall.DataModel.Customer

        NewUser.Customer_DateTime = Now()
        NewUser.Customer_UserName = txtUserName.Text
        NewUser.Customer_Password = txtPassword.Text
        NewUser.Customer_FirstName = txtFirstName.Text
        NewUser.Customer_LastName = txtLastName.Text
        NewUser.Customer_EmailID = txtEmailID.Text
        NewUser.Customer_Mobile = txtMobileNo.Text
        NewUser.Customer_AcStatus = 0

        SQLDB.AddToCustomers(NewUser)
        SQLDB.SaveChanges()
        SQLDB.Dispose()

        panelForm.Visible = False
        panelMessage.Visible = True

        Dim encDoe As String = OneCall.Crypt.Encrypt(NewUser.Customer_ID, "1CallH0meCar3")


        Dim msg As String = ""
        msg = msg & "Hi " & txtFirstName.Text & " " & txtLastName.Text & "<br>"
        msg = msg & "<br>"
        msg = msg & "Thank you for registering with us." & "<br>" & "<br>"
        msg = msg & "This is the verification email send by the system to verify your email address. Please click the below link to verify your email address." & "<br>"
        msg = msg & "==============================================" & "<br>"
        msg = msg & "<a href='http://www.onecallhomecaresolution.com/ValidateEmail.aspx?id=" & encDoe & "'>http://www.onecallhomecaresolution.com/ValidateEmail.aspx?id=" & encDoe & "</a>" & "<br>"
        msg = msg & "==============================================" & "<br>"
        msg = msg & "" & "<br>"
        msg = msg & "Regards," & "<br>"
        msg = msg & "Customer service" & "<br>"
        msg = msg & "One Call Home Care Solution" & "<br>"
        msg = msg & "www.onecallhomecaresolution.com" & "<br>"

        OneCall.EmailGateway.EMailSender.SendWebEmail(txtEmailID.Text, "Verification email", msg)



    End Sub
End Class
